<?php
class frontAction extends rareAction{
	public function __construct($moduleName,$actionName){
		$this->context=rareContext::getContext();
		$this->moduleName=$moduleName;
		$this->actionName=$actionName;
		$this->viewFile=$this->context->getTemplateDir().$moduleName."/view/".$actionName.".php";
	}
	/**
	 *渲染指定模版 并返回内容 
	 * @param $viewFile
	 */
	public function fetch($viewFile=null){
		if(!empty($viewFile) && is_string($viewFile)){
			$pathArray=explode("/",$viewFile);
			if(count($pathArray)==1){
				$moduleName=$this->moduleName;
			}else{
				$moduleName=$pathArray[0]=="~"?$this->moduleName:$pathArray[0];
				array_shift($pathArray);
			}
			$this->viewFile=$this->context->getTemplateDir().$moduleName."/view/".join("/", $pathArray).".php";
		}
		if(!file_exists($this->viewFile))return;
		return rareView::render($this->vars, $this->viewFile);
	}
}
?>
